package com.ktwlsoft.fundmanage.fundFlow.processHandler.FundOutServiceTask;

import com.ktwlsoft.fundmanage.domain.business.SystemService;
import com.ktwlsoft.fundmanage.domain.entity.SkipConfig;
import com.ktwlsoft.fundmanage.domain.entity.TransferApply;
import com.ktwlsoft.fundmanage.fundFlow.processHandler.BaseServiceTask;
import org.activiti.engine.delegate.DelegateExecution;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class CheckWhetherSkip extends BaseServiceTask {

    private final SystemService systemService;

    public CheckWhetherSkip(SystemService systemService) {
        this.systemService = systemService;
    }

    @Override
    public void execute(DelegateExecution execution) {
        TransferApply transferApply = (TransferApply) execution.getVariable("transferApply");
        this.doContinue = systemService.isSkip(SkipConfig.SystemType.SECOND_HAND_HOUSE,transferApply.getCreatedAt());
        if(this.doContinue){
            transferApply.setAuditState(TransferApply.AuditStatus.PASSED);
            transferApply.setRemark("自动划款，已跳过！");
            transferApply.setAuthTime(new Date());
        }
    }
}
